package com.chinasofti.admin.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.chinasofti.manager.service.AdminLeaveService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Creator: <br>
 * Date: <br>
 * Description: <br>
 */
@Controller
@RequestMapping("/admin/leave")
public class AdminLeaveController {
    @Reference
    private AdminLeaveService adminLeaveService;

    @GetMapping("/list")
    public ModelAndView list(){
        ModelAndView mv = new ModelAndView("leave/list");
        mv.addObject("leaves", adminLeaveService.queryLeaveList());
        return mv;
    }

    @GetMapping("/pass/{id}")
    public ModelAndView pass(@PathVariable("id") Long id){
        adminLeaveService.operate(id, 1);
        return new ModelAndView("redirect:/admin/leave/list");
    }

    @GetMapping("/reject/{id}")
    public ModelAndView reject(@PathVariable("id") Long id){
        adminLeaveService.operate(id, 0);
        return new ModelAndView("redirect:/admin/leave/list");
    }

}
